import React from "react";
import MyContext from "./context.js";
import { useContext } from 'react';
const { Consumer } = MyContext;
console.log(Consumer);
function ChildCom2() {
  const { count } = useContext(MyContext)
  console.log(count)
  return (
    <Consumer>
      {(context) => {
        console.log(context);
        return (
          <div
            style={{
              border: "1px solid",
              width: "200px",
              userSelect: "none",
            }}
            onClick={() => context.setCount(context.count + 1)}
          >
            ChildCom2
            <div>count:{context.count}</div>
            <div>react19context默认值失效 name:{context.name}</div>
          </div>
        );
      }}
    </Consumer>
  );
}

export default ChildCom2;
